package com.run.motion.controller;

import java.util.List;

import com.run.motion.entity.Images;
import com.run.motion.service.IImagesService;
import com.run.motion.util.page.AjaxResult;
import com.run.motion.util.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 动态图片Controller
 * 
 * @author lyq
 * @date 2022-03-26
 */
@Api(tags = "动态图片")
@RestController
@RequestMapping("/dynamic/images")
public class ImagesController extends BaseController
{
    @Autowired
    private IImagesService imagesService;

    /**
     * 查询动态图片列表
     */
    @ApiOperation(value = "查询动态图片列表")
    @GetMapping("/list")
    public TableDataInfo list(Images images)
    {
        startPage();
        List<Images> list = imagesService.selectImagesList(images);
        return getDataTable(list);
    }




    /**
     * 获取动态图片详细信息
     */
    @ApiOperation(value = "获取动态图片详细信息")
    @GetMapping(value = "/{imgId}")
    public AjaxResult getInfo(@PathVariable("imgId") Long imgId)
    {
        return AjaxResult.success(imagesService.selectImagesByImgId(imgId));
    }

    /**
     * 根据mid获取动态图片详细信息
     */
    @ApiOperation(value = "根据mid获取动态图片详细信息")
    @GetMapping(value = "/list/{mid}")
    public AjaxResult getInfoList(@PathVariable("mid") Long mid)
    {
        return AjaxResult.success(imagesService.selectImagesByMId(mid));
    }

    /**
     * 新增动态图片
     */
    @PostMapping
    public AjaxResult add(@RequestBody Images images)
    {
        return toAjax(imagesService.insertImages(images));
    }

    /**
     * 修改动态图片
     */
    @PutMapping
    public AjaxResult edit(@RequestBody Images images)
    {
        return toAjax(imagesService.updateImages(images));
    }

    /**
     * 删除动态图片
     */
	@DeleteMapping("/{imgIds}")
    public AjaxResult remove(@PathVariable Long[] imgIds)
    {
        return toAjax(imagesService.deleteImagesByImgIds(imgIds));
    }
}
